package com.pms.util;

import java.util.List;

public class Page<T> {
	private int pageSize;
	private int pageNum;
	private int offSet;
	private Long totalPages;
	private Long totalCount;
	private List<T> result;
	public Page(int pageSize,Long totalCount,int pageNum){
		this.setPageSize(pageSize);
		this.setTotalCount(totalCount);
		this.setPageNum(pageNum);
		
		
	}
	public int getPageSize() {
		return pageSize;
	}
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}
	public int getPageNum() {
		return pageNum;
	}
	public void setPageNum(int pageNum) {
		this.pageNum = pageNum;
		if(pageNum<1){
			this.pageNum=1;
			
		}else if(pageNum>getTotalPages()){
			this.pageNum=getTotalPages().intValue();
		}
		setOffSet((this.pageNum-1)*getPageSize());
	}
	public int getOffSet() {
		return offSet;
	}
	public void setOffSet(int offSet) {
		this.offSet = offSet;
	}
	public Long getTotalPages() {
		return totalPages;
	}
	private void setTotalPages(Long totalPages) {
		this.totalPages = totalPages;
	}
	public long getTotalCount() {
		return totalCount;
	}
	public void setTotalCount(Long totalCount) {
		this.totalCount = totalCount;
		Long result=totalCount/getPageSize();
		if(totalCount%pageSize!=0){
			result+=1;
		}
		setTotalPages(result);
	}
	public List<T> getResult() {
		return result;
	}
	public void setResult(List<T> result) {
		this.result = result;
	}
	
}
